<template>
  <div v-if="visible" class="loading-overlay">
    <div class="loading-backdrop"></div>
    <div class="loading-content">
      <div class="loading-spinner">
        <div class="spinner-circle"></div>
        <div class="spinner-circle"></div>
        <div class="spinner-circle"></div>
        <div class="spinner-circle"></div>
        <div class="spinner-circle"></div>
        <div class="spinner-circle"></div>
      </div>
      <div class="loading-text">{{ message || '正在处理中' }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">

// 添加组件名称声明
defineOptions({
  name: 'LoadingDots'
})

// Props
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  message: {
    type: String,
    default: ''
  }
})
</script>

<style scoped>
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  transition: all 0.3s ease;
}

.loading-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.5);
  z-index: -1;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  max-width: 80%;
}

.loading-spinner {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.spinner-circle {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--n-primary-color);
  margin: 0 2px;
  animation: spinner-bounce 1.4s infinite ease-in-out both;
}

.spinner-circle:nth-child(1) {
  animation-delay: -0.32s;
}

.spinner-circle:nth-child(2) {
  animation-delay: -0.16s;
}

.spinner-circle:nth-child(3) {
  animation-delay: 0s;
}

.spinner-circle:nth-child(4) {
  animation-delay: 0.16s;
}

.spinner-circle:nth-child(5) {
  animation-delay: 0.32s;
}

.spinner-circle:nth-child(6) {
  animation-delay: 0.48s;
}

.loading-text {
  font-size: 16px;
  color: var(--n-text-color-2);
  margin-bottom: 8px;
  font-weight: 500;
}

@keyframes spinner-bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}
</style>